let count = parseInt(input_arr[0])
=[]
for(i=0;i<count;i++){
    let arr=input_arr[i+1].split(' ')
    let student_infos_object={
        sex:arr[0],
        student_name:arr[1],
    }
    student_infos_arr.push(student_infos_object)
}
let girls=student_infos_arr.filter((item)=>item.sex==='0')
let boys=student_infos_arr.filter((item)=>item.sex==='1')
let pair_count=0
for(i=0;i<student_infos_arr.length;i++){
    if(pair_count===count/2){
        break
    }
    let student_infos_object=student_infos_arr[i]
    if(student_infos_object.sex==='0'){
        let boy=boys.pop()
        console.log(`${student_infos_object.student_name}${boy.student_name}`);
    }
    else if(student_infos_object.sex==='1'){
        let girl=girls.pop()
    console.log(`${student_infos_object.student_name}${girl.student_name}`);
}}